import { BasicColumn, FormSchema, BasicTable, useTable, useRender } from "@/components/Table";
import Toolbar from "@/components/ViewComponents/Toolbar";
import { useTranslation } from "react-i18next";
import "./index.less";
import { patientOrdersPage } from "@/api/MedicalExamination";

export default function index() {
	const { t } = useTranslation();

	const searchFormSchema: FormSchema[] = [
		{
			label: t("kevin_ui.patient_id"),
			field: "patientId",
			component: "Input"
		},
		{
			label: t("flandre_ui.name"),
			field: "fullName",
			component: "Input"
		},
		{
			label: t("kevin_ui.department"),
			field: "department",
			component: "Input"
		},
		{
			label: t("flandre_ui.pat_cardno"),
			component: "Input",
			field: "patCardno"
		}
	];
	const columns: BasicColumn[] = [
		{
			title: t("kevin_ui.time"),
			dataIndex: "time",
			render: (_, record) => useRender.renderDate(record.createdTime, "HH:mm")
		},
		{
			title: t("flandre_ui.dept_name"),
			dataIndex: "deptName"
		},
		{
			title: t("kevin_ui.date"),
			dataIndex: "date",
			render: (_, record) => useRender.renderDate(record.createdTime, "YYYY-MM-DD")
		},
		{
			title: t("kevin_ui.patient_type"),
			dataIndex: "patientType"
		},
		{
			title: t("kevin_ui.content"),
			dataIndex: "rxDiagnosis"
		},
		{
			title: t("kevin_ui.amount"),
			dataIndex: "totalPrice"
		}
	];
	const [patServicesTable] = useTable({
		// dataSource: [
		// 	{
		// 		time: "10:41",
		// 		deptName: "clinic",
		// 		date: "2025-01-23",
		// 		patientType: "1",
		// 		content: "examination fee",
		// 		amount: 9.99
		// 	}
		// ],
		api: patientOrdersPage,
		columns,
		formConfig: {
			labelWidth: 120,
			schemas: searchFormSchema,
			showActionButtonGroup: true
		},
		useSearchForm: true
	});

	return (
		<div className="statusDialog page">
			<div className="page-content">
				<BasicTable register={patServicesTable}></BasicTable>
			</div>
			<Toolbar btnList={[{ key: "print", disabled: true }]} />
		</div>
	);
}
